<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.gxgyl.com All rights reserved.

// +----------------------------------------------------------------------
// | Author: Liuyu
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\shiyao;

use cores\BaseModel;

/**
 * 模型
 * Class
 * @package app\common\model
 */
class ProjectTestee extends BaseModel {
	// 定义表名
	protected $name = 'shiyao_project_center_testee';

	// 定义主键
	protected $pk = 'id';

	/**
	 * 追加字段
	 * @var array
	 */
	protected $append = ['date', 'relation_text', 'sex_text'];

	public function getSexTextAttr($value, $data) {

		if ($data['sex'] == 1) {
			$sex = '男';
		} else {
			$sex = '女';
		}

		return $sex;
	}
	public function getRelationTextAttr($value, $data) {

		switch ($data['relation']) {
		case 1:
			$relation = '本人';
			break;
		case 2:
			$relation = '亲属';
			break;
		case 3:
			$relation = '朋友';
			break;
		case 4:
			$relation = '同事';
			break;

		default:
			$relation = '其他';
			break;
		}

		return $relation;
	}
	public function getIcfDateAttr($value, $data) {
		return Date('Y-m-d', $data['icf_date']);
	}
	public function getDateAttr($value, $data) {
		return Date('Y-m-d', $data['icf_date']);
	}

	/**
	 * 关联文件库
	 * @return \think\model\relation\BelongsTo
	 */
	public function idcardAvatar() {
		return $this->hasOne('app\\common\\model\\UploadFile', 'file_id', 'idcard_avatar_id');
	}
	/**
	 * 关联文件库
	 * @return \think\model\relation\BelongsTo
	 */
	public function idcardFile() {
		return $this->hasOne('app\\common\\model\\UploadFile', 'file_id', 'idcard_file_id');
	}
	/**
	 * 关联文件库
	 * @return \think\model\relation\BelongsTo
	 */
	public function bank() {
		return $this->hasOne('app\\common\\model\\UploadFile', 'file_id', 'bank_file_id');
	}

	public function certFile() {
		return $this->hasOne('app\\common\\model\\UploadFile', 'file_id', 'cert_file_id');
	}

	public function project() {
		return $this->hasOne('Project', 'project_id', 'project_id');
	}

}
